import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import CourseItem from '@/components/CourseItem' // secondary package based on el-pagination
import {getTrainingCourseList} from "@/api/studyspace"
export default {
  name: "my-trainclass",
  components: {
    Pagination,
    CourseItem,
  },
  data() {
    return {
      list:[],
      moreFlag:true,
    }
  },
  methods: {
    getList() {
      if ( this.list.length == 0) {
        var queryDate = this.$utils.getDate();
      }else {
        var queryDate = this.list[this.list.length -1 ].date;
      }
      var data = {
        historyDate: "",
        queryDate:queryDate,
        queryType: ""
      }
      getTrainingCourseList(data).then((response) =>{
        if (response.data.length < 5) {
          this.moreFlag = false;
        }
        this.list =  this.list.concat(response.data);
      }).catch((err) =>{
        this.$message.error(err.message || 'error')
      });
    }
  },
  mounted() {
    this.getList()
  }
}
